package com.sunny.l30;

public class Solution {
    public int maxProfit(int[] prices) {
        int b = Integer.MIN_VALUE;
        int s = 0;
        for(int price: prices){
            if(b < -1*price){
                b = -1*price;
            }
            if(s < b + price){
                s = b + price;
            }
        }
        return s;
    }
}
